
function openWebsocket(addr, open, close){
    var ws = new WebSocket(addr);
    ws.onopen = open
    ws.onclose = close
    ws.onmessage = function (evt) {
            console.info(evt.data)
        var data = $.evalJSON(evt.data);
        if (data.func){
            func = eval(data.func)
            func(data)
        }else{
            alert("返回格式错误")
        }
    };
    return ws
}

function getNow() {
    var d = new Date();
    return d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds()
}

function getLeft(e){
    var offset=e.offsetLeft;
    if(e.offsetParent!=null) offset+=getLeft(e.offsetParent);
    return offset;
}

